Exercise: Hash Tables
Implement the addSlow() method in LinearHashTable.
We'll cover the following
Task#
Implement an addSlow() method for adding an element x to a LinearHashTable, which simply stores x in the first null array entry it finds.
Sample input
100 random elements
Expected output
The expected output will be as follows:
Adding
Searching
The value 96 is not found
The value 88 is not found
The value 62 is found
The value 23 is not found
The value 2 is found
The value 22 is not found
The value 89 is found
The value 61 is not found
The value 50 is not found
The value 4 is not found
Try it yourself first. If you have trouble getting to the solution, you can move to the solution section to see how to solve the problem. We’ll go through the in-depth solution in the next lesson.
Good luck!
Note: You must implement the method
addSlow()in the below code starting at line 57.
main.py
base.py
utils.py
Task to implement addSlow() in LinearHashTable
Discussion on Hash Tables
Solution: Hash Tables